package org.fungene.controller;

import java.io.BufferedReader;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.fungene.services.kegg.KEGGMapLauncher;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

public class KEGGController extends AbstractController {

	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		BufferedReader bReader = request.getReader();
		String line = "";
		StringBuffer data = new StringBuffer();
		while ((line = bReader.readLine()) != null) {
			data.append(line);
		}
		String[] idList = data.toString().split(",");
		KEGGMapLauncher keggMapLauncher = new KEGGMapLauncher(idList);
		String pathwaysMap = keggMapLauncher.launch();
		
		PrintWriter pr = response.getWriter();
		
		pr.println(pathwaysMap);
		pr.close();

		return null;
	}

}
